/**
 * Created by easy on 15/5/21.
 */
mc.getFileExtension = function(filename){
    var filenamelength=filename.split(".").length;
    return filename.split(".")[(filenamelength-1)];
};
mc.judgeFileSize = function(filesize){//转换文件大小
    var formatfilesize;
    var dotnum;
    var subdot;
    if(filesize>=0&&filesize<1024){
        formatfilesize=filesize+' B';
    }else if(filesize>=1024&&filesize<1048576){
        filesize=filesize/1024;
        if(filesize.toString().indexOf(".") != -1)
        {
            dotnum = filesize.toString().split(".")[1].length;
            if(dotnum>2){
                filesize=filesize.toFixed(2);
                subdot = parseInt((filesize.toString().split(".")[1]).substr(0,2));
                if(subdot==0){
                    filesize=filesize.toString().split(".")[0];
                }else if(subdot%10==0) {
                    filesize=filesize.toString().split(".")[0]+'.'+(subdot/10);
                }
            }
        }
        formatfilesize=filesize+' KB';
    }else if(filesize>=1048576&&filesize<1073741824){
        filesize=(filesize/1048576);
        if(filesize.toString().indexOf(".") != -1)
        {
            dotnum = filesize.toString().split(".")[1].length;
            if(dotnum>2){
                filesize=filesize.toFixed(2);
                subdot = parseInt((filesize.toString().split(".")[1]).substr(0,2));
                if(subdot==0){
                    filesize=filesize.toString().split(".")[0];
                }else if(subdot%10==0) {
                    filesize=filesize.toString().split(".")[0]+'.'+(subdot/10);
                }
            }
        }
        formatfilesize=filesize+' MB';
    }else if(filesize>=1073741824){
        filesize=(filesize/1073741824);
        if(filesize.toString().indexOf(".") != -1)
        {
            dotnum = filesize.toString().split(".")[1].length;
            if(dotnum>2){
                filesize=filesize.toFixed(2);
                subdot = parseInt((filesize.toString().split(".")[1]).substr(0,2));
                if(subdot==0){
                    filesize=filesize.toString().split(".")[0];
                }else if(subdot%10==0) {
                    filesize=filesize.toString().split(".")[0]+'.'+(subdot/10);
                }
            }
        }
        formatfilesize=filesize+' GB';
    }
    return formatfilesize
};
mc.judgeFileType = function(extension){//判断文件类型
    var filetype;
    extension=extension.toLowerCase();
    if(extension=='doc'||extension=='docx'||extension=='wps'){
        filetype='word';
    }else if(extension=='et'||extension=='xls'||extension=='xlsx'){
        filetype='excel';
    }else if(extension=='dps'||extension=='ppt'||extension=='pptx'){
        filetype='powerpoint';
    }else if(extension=='pdf'){
        filetype='pdf';
    }else if(extension=='png'||extension=='jpg'||extension=='jpeg'||extension=='bmp'||extension=='gif'||extension=='tif'){
        filetype='image';
    }else if(extension=='mp3'||extension=='wav'||extension=='wma'||extension=='ogg'||extension=='aac'){
        filetype='sound';
    }else if(extension=='wmv'||extension=='avi'||extension=='3gp'||extension=='flv'||extension=='mkv'){
        filetype='video';
    }else if(extension=='txt'){
        filetype='txt';
    }else if(extension=='zip'||extension=='rar'){
        filetype='compress';
    }else{
        filetype='others';
    }
    return filetype;
};